package top.lyjwn.ajui.util;

import android.content.Context;

import com.alibaba.fastjson.JSONObject;

import top.lyjwn.ajui.AJUIApplication;
import top.lyjwn.ajui.data.Token;
import top.lyjwn.ajui.util.store.LibertyStoreUtil;

/**
 * token工具
 *
 * @author luoyujie
 */
public class TokenUtil {

  public static Token getToken(){
      String token_json = (String)LibertyStoreUtil.get(AJUIApplication.getContext(), "token");
       if (token_json!=null){
           Token token = JSONObject.parseObject(token_json, Token.class);
           return  token;
       }
       return null;
   }

    public static void setToken(Token token){
        LibertyStoreUtil.put(AJUIApplication.getContext(), "token",JSONObject.toJSONString(token));
    }
}
